//
//  AlarmPickView.m
//  haolaDoc
//
//  Created by WayneHao on 2017/5/20.
//  Copyright © 2017年 deyi. All rights reserved.
//

#import "AlarmPickView.h"
@interface AlarmPickView()<UIPickerViewDataSource,UIPickerViewDelegate>

@property(nonatomic,strong) NSArray *data;

@end

@implementation AlarmPickView


/*
 // Only override drawRect: if you perform custom drawing.
 // An empty implementation adversely affects performance during animation.
 - (void)drawRect:(CGRect)rect {
 // Drawing code
 }
 */
-(NSArray *)data{
    if(_data==nil){
        _data=@[@"不提醒",@"提醒"];
    }
    return _data;
}
-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.delegate=self;
        self.dataSource=self;
        _selectedIndex=@0;
    }
    return self;
}
#pragma 返回多少组数据
-(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView{
    return 1;
}

-(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component{
    return [self.data count];
}

-(NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component{
    return [self.data objectAtIndex:row];
}

-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component{
    [_outputView setText:[self.data objectAtIndex:row]];
    _selectedIndex=[[NSNumber alloc]initWithInteger:row];
}

@end
